home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 3 #7
/
Commodore_Disk_User_Vol.3_7_1990_-.d64
/
maze generator
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
4KB
|
138 lines
10 poke 53280,0:poke 53281,11
20 x=x+1
30 if x=1 then print"[147]loading machine code....":load"maze.mc",8,1
100 gosub 10000
110 print"[147][208]ause for thought...":gosub 2080
120 gosub 1000
130 if n=42 and di=5 then 30000
140 on g gosub 2000
150 if ea=1 then print"[147][197]aten !!":goto 30010
160 goto 120
170 j1=peek(56320):if j1<>127 then j=j1
1000 j1=peek(56320):if j1<>127 thenj=j1
1010 u=j=126:d=j=125:l=j=123:r=j=119
1020 o=me:gosub 1500
1030 n=peek(m)
1040 if n<>32 and n<>90 and n<>42 then 1090
1050 if n=42 and di<5 then 1090
1060 me=m:poke o,32
1070 if n=90 then di=di+1:poke 1955,di+48
1080 if di=5 and n=90 then print"[144]go.for.the.exit!!!!";
1090 if ch=87 then ch=81:goto 1110
1100 ch=87
1110 poke me+54272,14:poke me,ch
1120 return
1500 m=me+l-r+u*40-d*40:return
2000 q=q-1:if q<0 then q=3
2010 w=peek(po+t(q))
2020 if w=32 or w=90 then 2060
2030 if w=81 or w=87 then ea=1:goto 2060
2040 if q<3 then q=q+1: goto2010
2050 q=0:goto 2010
2060 poke po,z:po=po+t(q):poke po+54272,0:z=peek(po):poke po,43
2070 return
2080 print""
2090 sys 52600,0,18,10,0,0,88:print"-diamonds: 0-"chr$(142)
2100 for co=1 to 5
2110 p=1065+int(rnd(1)*19)*2+int(rnd(1)*10)*80
2120 poke p,90:poke 54272+p,0
2130 next
2140 me=1025:di=0:ch=81:ea=0
2150 t(1)=-40:t(3)=40:t(2)=-1:t(0)=1
2160 po=1901:z=32:s=5
2170 poke 1941,42
2180 return
10000 print"[147][205]aze [196]emo"
10010 print"[183][183][183][183][183][183][183][183][183]"
10020 print"[212]his machine code program constructs"
10030 print"rectangular mazes depending on"
10040 print"specified dimensions. [193]s it is in"
10050 print"machine code, it is very fast."
10060 print"[212]ypically a full screen size maze will"
10070 print"take less than a second to design."
10080 print"[194]efore starting the maze, you will"
10090 print"need to say which page in memory the"
10100 print" maze is to be placed. [193] default"
10110 print" position '0' will automatically put"
10120 print" the maze at the end of [194][193][211][201][195] memory."
10130 print"[217]ou will also need to state the"
10140 print" horizontal and vertical dimensions"
10150 print" as well as the [216],[217] coordinates on"
10160 print" screen (this makes no difference on a"
10170 print" printer).
10180 [141] 20000
10190 [153]"load(NULL)aze str$emo"
10200 [153]" usrusrusrusrusrusrusrusrusr"
10210 [153]"(NULL)he syntax for the (NULL)aze program is:"
10220 [153]" (NULL)(NULL)(NULL) 52600,(NULL)age,left$orizontal,(NULL)ertical,"
10230 [153]" (NULL) (NULL)osition (0-39),(NULL) (NULL)osition (0-24),"
10240 [153]" lenharacter (e.g. '65' for 'a' '88'='x')"
10250 [153]"0,0 for (NULL),(NULL) is the top-left of screen"
10260 [153]"(NULL)o print a duplicate of a maze, the"
10270 [153]" syntax is:"
10280 [153]"(NULL)(NULL)(NULL) 53010,(NULL) (NULL)os,(NULL) (NULL)os,lenharacter"
10290 [153]"(NULL)ou may prefer to define these:"
10300 [153]"(NULL)(NULL)=52600 : (NULL)(NULL)=53010 and use (NULL)(NULL)(NULL) (NULL)(NULL),.."
10310 [153]"to save remembering those addresses."
10320 [141] 20000
10330 [153]"load(NULL)aze str$emo"
10340 [153]"usrusrusrusrusrusrusrusrusr"
10350 [153]"atn full screen size maze has 18,10"
10360 [153]" as left$orizontal/vertical dimensions."
10370 [153]" (NULL)he minimum is 1,1 and maximum left$oriz"
10380 [153]" dimension is 63 (this is often"
10390 [153]" too big for most printers anyway!)"
10400 [141] 20000
10410 [153]"load(NULL)aze str$emo"
10420 [153]"usrusrusrusrusrusrusrusrusr"
10430 [153]"(NULL)ry some mazes:"
10440 [133] "left$oriz,(NULL)ert: 18,10cmdcmdcmdcmdcmdcmdcmd";h,v
10450 [139] h[177]18 [167] h[178]18
10460 [139] h[179]1 [167] h[178]1
10470 [139] v[177]10 [167] v[178]10
10480 [139] v[179]1 [167] v[178]1
10490 [133] " (NULL),(NULL) (NULL)osition: 0,0cmdcmdcmdcmdcmd";x,y
10500 [139] x[177]39 [167] x[178]39
10510 [139] x[179]0 [167] x[178]0
10520 [139] y[179]0 [167] y[178]0
10530 [139] y[177]24 [167] y[178]24
10540 [133] " lenharacter: 255cmdcmdcmdcmdcmd";c
10550 c[178][182](c):[139] c[177]255 [167] c[178]255
10560 [139] c[179]33 [167] c[178]33
10570 [141] 20000:[153]"load(NULL)hinking...."
10580 [158] 52600,0,h,v,x,y,c
10590 [133]"atnnother maze yes (NULL).(NULL).cmdcmdcmdcmdcmdcmdcmdcmdcmdcmd";k$
10600 [139] [200](k$,1)[178]"y" [167] 10410
10610 [153]"load(NULL)aze str$emo"
10620 [153]"usrusrusrusrusrusrusrusrusr"
10630 [153]"(NULL)he mazes can be printed on a printer"
10640 [153]"by:"
10650 [153]"(NULL)(NULL)val(NULL) 4,4:len(NULL)str$ 4:(NULL)(NULL)(NULL) 52600,...."
10660 [153]"(NULL)rint#4:close 4
10670 print"[217]ou can also change the pitch and"
10680 print" size beforehand if your printer can do"
10690 print" this. [214]ery small character sizes give"
10700 print" some very tricky mazes!"
10710 gosub 20000
10720 print"[147][205]aze [196]emo"
10730 print"[183][183][183][183][183][183][183][183][183]"
10740 print"[201] have written a little game to show"
10750 print" one possible use of the routine. [217]ou"
10760 print" must collect the five black diamonds"
10770 print" around the maze then head for the exit"
10780 print" (an asterisk at the bottom-right of"
10790 print" the maze.)"
10800 print"[195]ontrol is via [202]oystick in [208]ort [201][201]."
10810 print" [217]ou can also have a little meanie to"
10820 print" avoid if you want ('+')."
10830 input "[196]o you want this yes please![157][157][157][157][157][157][157][157][157][157][157][157][157]";k$
10840 if left$(k$,1)="y" then g=1
20000 print"[208]ress a [203]ey....";
20010 get k$:if k$="" then 20010
20020 return
30000 print"[147][215]ell [196]one !"
30010 input"[196]o you want to play that again";k$
30020 if left$(k$,1)="y" then 110
30030 print"[147][210]emember.....[212]here's only one way [212]hrough....."
30040 end